home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok71.lha
/
ROM20
/
ROM20.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
25KB
|
927 lines
(*********************************************************************
:Program. ROM20
:Contents. Calculator to evaluate numeric expressions
:Contents. like "sin(x)/epsilon*(time*7.2E3)"
:Contents. Works in CON:-Windows
:Author. Stefan Salewski
:Address. Stefan Salewski, Stolper Weg 3, D-2160 Stade
:Copyright. © 1992 by S. Salewski, SHAREWARE, see file ROM20.doc
:Language. Oberon
:Translator. Amiga-Oberon-Compiler V2.14d
:History. V1.0 11. MAY 1992
*********************************************************************)
MODULE ROM20;
IMPORT
ASCII,
AVL,
Beep,
Break, (* we don't really need it *)
Conversions,
Dos, (* print results unbuffered *)
Formula, (* this module does all the work *)
Intuition, (* only to get the printwidth and DisplayBeep()*)
io,
LRC2:LongRealConversions2, (* from AMOK#58 *)
MATHLIB,
NoGuru,
Requests,
SecureDos,
Strings,
TF:TurboFiles; (* Version 2.1 *)
CONST
Space=' ';
PrinterName="PRT:";
ConfigName="S:ROM20.config";
ValuesName="S:ROM20.values";
IsOn=" is on";
IsOff=" is off";
LastResultName="#";
UseVarName="x";
MaxDigits=14;
PME=7; (* Additional space in WriteReal() for -n.mE-123 *)
MaxCommands=43;
ResetColor="\e[0m";
Clear="\ec";
Color3="\e[33m";
CRString0=" ROM20 V1.0 This version is only for the AMOK-FD-Library";
CRString1=" A plain but powerful calculator for numeric expressions";
CRString2=" This program is not in the Public Domain, but SHAREWARE";
CRString3=" © 1992 by Stefan Salewski (Type ? for help)";
OoM="Not enougth Memory!";
ImpossibleError="I thought this is an impossible error!";
NoError=0;
PrinterError=1;
FileWriteError=2;
VariationError=3;
TYPE
String20=ARRAY 20 OF CHAR;
String80=ARRAY 80 OF CHAR;
String512=ARRAY 512 OF CHAR;
InfoText=ARRAY 4 OF String80;
CONST
IText=InfoText("All ok",
"Can't use printer",
"Can't write to file",
"Can't calculate variation"
);
TYPE
Command=RECORD
name:String20;
id:INTEGER;
END;
Commands=ARRAY MaxCommands OF Command;
ComNodePtr=POINTER TO ComNode;
ComNode= RECORD (AVL.SNode);
id:INTEGER
END;
CONST (* Commands *)
Calculate=0;
Quit=1; Point=2;
Help=3; Info=4; Questionmark=Help;
PrinterOn=5; PrinterOff=6;
OpenFile=7; CloseFile=8;
PrintResult=9; PrintAll=10;
LoadValues=11; SaveValues=12;
LoadConfig=13; SaveConfig=14;
FormulaOn=15; FormulaOff=16;
ExponentOn=17; ExponentOff=18;
LeftJustify=19; RightJustify=20;
AutoExpoOn=21; AutoExpoOff=22;
ShowCommands=23; ShowFunctions=24; ShowValues=25;
Format=26; SetFillChar=27;
RemoveValue=28; DisposeAllValues=29;
ResetStatistics=30; StatisticsUndo=31;
StatisticsOn=32; StatisticsOff=33;
SumOfInputs=34; MeanValue=35;
SumOfSquares=36; StatisticsCounter=37;
Variation=38; (* german Varianz *)
StandardDeviation=39; (* german StandardAbweichung or Streuung *)
TotalDigits=40; DigitsBehindPoint=41; Empty=42;
Com=Commands('PrinterOn',PrinterOn,
'PrinterOff',PrinterOff,
'PrintResult',PrintResult,
'PrintAll',PrintAll,
'LoadValues',LoadValues,
'SaveValues',SaveValues,
'Quit',Quit,
'Help',Help,
'',Empty,
'?',Questionmark,
'ShowCommands',ShowCommands,
'ShowFunctions',ShowFunctions,
'ShowValues',ShowValues,
'Format',Format,
'.',Point,
'OpenFile',OpenFile,
'CloseFile',CloseFile,
'LoadConfig',LoadConfig,
'SaveConfig',SaveConfig,
'RemoveValue',RemoveValue,
'DisposeAllValues',DisposeAllValues,
'FormulaOn',FormulaOn,
'FormulaOff',FormulaOff,
'ResetStatistics',ResetStatistics,
'StatisticsOn',StatisticsOn,
'StatisticsOff',StatisticsOff,
'SumOfInputs',SumOfInputs,
'MeanValue',MeanValue,
'SumOfSquares',SumOfSquares,
'Variation',Variation,
'StandardDeviation',StandardDeviation,
'StatisticsUndo',StatisticsUndo,
'ExponentOn',ExponentOn,
'ExponentOff',ExponentOff,
'TotalDigits',TotalDigits,
'DigitsBehindPoint',DigitsBehindPoint,
'Info',Info,
'StatisticsCounter',StatisticsCounter,
'SetFillChar',SetFillChar,
'LeftJustify',LeftJustify,
'RightJustify',RightJustify,
'AutoExpoOn',AutoExpoOn,
'AutoExpoOff',AutoExpoOff
);
TYPE
Config=RECORD
gs:INTEGER;
nks:INTEGER;
expo:BOOLEAN;
autoExpo:BOOLEAN;
leftJustify:BOOLEAN;
printAll:BOOLEAN;
fillChar:CHAR;
END;
Statistics=RECORD
sum:LONGREAL;
sumOfSquares:LONGREAL;
lastInput:LONGREAL;
counter:LONGINT;
on:BOOLEAN;
canUndo:BOOLEAN;
END;
Settings=RECORD
lastResultIndex:INTEGER;
printWidth:INTEGER;
useVarIndex:INTEGER;
error:INTEGER;
filename:String80;
useFormulaExpression:String80;
printerOn:BOOLEAN;
fileOpen:BOOLEAN;
useFormula:BOOLEAN;
END;
VAR
input,tmp1,tmp2:String512;
command:AVL.String;
root:AVL.SRoot;
el:AVL.SNodePtr;
formula:Formula.Formula;
useFormula:Formula.Formula;
file:TF.File;
printerPtr:Dos.FileHandlePtr;
config:Config;
statistics:Statistics;
settings:Settings;
l:LONGINT;
id:INTEGER;
PROCEDURE ImpErr;
BEGIN Requests.Assert(FALSE,ImpossibleError)
END ImpErr;
PROCEDURE WriteErrorLn(str:ARRAY OF CHAR);
(* $CopyArrays- *)
BEGIN
Beep.Beep(TRUE);
Intuition.DisplayBeep(NIL);
io.WriteString(str);
io.WriteLn;
END WriteErrorLn;
PROCEDURE WriteString(str:ARRAY OF CHAR);
(* $CopyArrays- *)
VAR i:INTEGER;
BEGIN
io.WriteString(str);
IF settings.fileOpen THEN
IF NOT TF.WriteString(file,str) THEN
settings.error:=FileWriteError END;
END;
IF settings.printerOn THEN
i:=Strings.Length(str);
IF Dos.Write(printerPtr,str,i)<i THEN
settings.error:=PrinterError END;
END;
END WriteString;
PROCEDURE Write(c:CHAR);
BEGIN
io.Write(c);
IF settings.fileOpen THEN
IF NOT TF.WriteChar(file,c) THEN
settings.error:=FileWriteError END;
END;
IF settings.printerOn THEN
IF Dos.Write(printerPtr,c,1)<1 THEN
settings.error:=PrinterError END;
END;
END Write;
PROCEDURE WriteLn;
BEGIN
Write(ASCII.lf);
END WriteLn;
PROCEDURE* WriteStringLn(str:ARRAY OF CHAR);
(* $CopyArrays- *)
BEGIN
WriteString(str);
WriteLn;
END WriteStringLn;
PROCEDURE WriteInt(l:LONGINT;n:INTEGER);
VAR
str:ARRAY 16 OF CHAR;
BEGIN
IF NOT Conversions.IntToString(l,str,n) THEN ImpErr END;
WriteStringLn(str);
END WriteInt;
PROCEDURE WriteReal(x:LONGREAL);
VAR str: ARRAY (MaxDigits+PME) OF CHAR;
BEGIN
IF LRC2.RealToString(x,str,config.gs,config.nks,config.expo OR
(config.autoExpo AND (ABS(x)<1)),
config.leftJustify) THEN
WriteString(" =");
WriteStringLn(str)
ELSE
ImpErr;
END;
END WriteReal;
PROCEDURE WriteRealRemember(x:LONGREAL);
BEGIN
WriteReal(x);
Formula.ChangeValue(settings.lastResultIndex,x)
END WriteRealRemember;
PROCEDURE WriteFillChar(n:INTEGER);
VAR
str:ARRAY 256 OF CHAR;
BEGIN
IF n<0 THEN ImpErr END;
IF n>255 THEN n:=255 END;
str[n]:=0X;
WHILE n>0 DO
DEC(n);
str[n]:=config.fillChar
END;
WriteString(str);
END WriteFillChar;
PROCEDURE AddCommandsToAVL;
VAR
el:ComNodePtr;
i:INTEGER;
BEGIN
i:=0;
WHILE i<MaxCommands DO
NEW(el);
Requests.Assert(el#NIL,OoM);
COPY(Com[i].name,el.name);
el.id:=Com[i].id;
IF NOT AVL.SAdd(root,el) THEN ImpErr END;
INC(i);
END;
END AddCommandsToAVL;
PROCEDURE SaveConfigP(name:ARRAY OF CHAR):BOOLEAN;
(* $CopyArrays- *)
VAR
f:TF.File;
ok:BOOLEAN;
BEGIN
IF name="" THEN name:=ConfigName END;
IF TF.Open(f,name,SIZE(Config),TF.newFile) THEN
ok:=TF.Write(f,config);
RETURN TF.Close(f) AND ok;
ELSE
RETURN FALSE
END;
END SaveConfigP;
PROCEDURE LoadConfigP(name:ARRAY OF CHAR):BOOLEAN;
(* $CopyArrays- *)
VAR
f:TF.File;
l:LONGINT;
ok:BOOLEAN;
BEGIN
IF name="" THEN name:=ConfigName END;
IF TF.Exists(name,l) AND (l=SIZE(Config)) THEN
IF TF.Open(f,name,SIZE(Config),TF.oldFile) THEN
ok:=TF.Read(f,config);
RETURN TF.Close(f) AND ok;
ELSE
RETURN FALSE
END;
ELSE
RETURN FALSE
END;
END LoadConfigP;
PROCEDURE GetPrintWidth;
VAR
prefs:Intuition.Preferences;
BEGIN
Intuition.GetPrefs(prefs,SIZE(prefs));
settings.printWidth:=prefs.printRightMargin-prefs.printLeftMargin;
END GetPrintWidth;
PROCEDURE InitLastResult;
BEGIN
IF NOT (Formula.DefineValue(LastResultName,0,TRUE,"") AND
Formula.GetIndex(LastResultName,settings.lastResultIndex)) THEN
ImpErr
END;
END InitLastResult;
PROCEDURE InitUseVar;
BEGIN
IF NOT (Formula.DefineValue(UseVarName,0,TRUE,"") AND
Formula.GetIndex(UseVarName,settings.useVarIndex)) THEN
ImpErr
END;
END InitUseVar;
PROCEDURE InitStatistics;
BEGIN
statistics.sum:=0;
statistics.sumOfSquares:=0;
statistics.lastInput:=0;
statistics.counter:=0;
statistics.on:=TRUE;
statistics.canUndo:=FALSE;
END InitStatistics;
PROCEDURE InitConfig;
BEGIN
IF NOT LoadConfigP(ConfigName) THEN
config.gs:=8;
config.nks:=8;
config.expo:=FALSE;
config.autoExpo:=FALSE;
config.leftJustify:=TRUE;
config.printAll:=FALSE;
config.fillChar:=Space;
END;
END InitConfig;
PROCEDURE InitSettings;
BEGIN
GetPrintWidth;
settings.lastResultIndex:=-1;
settings.useVarIndex:=-1;
settings.error:=NoError;
settings.filename:="";
settings.useFormulaExpression:="";
settings.printerOn:=FALSE;
settings.fileOpen:=FALSE;
settings.useFormula:=FALSE;
END InitSettings;
PROCEDURE InitAll;
BEGIN
printerPtr:=NIL;
file.res:=TF.notOpen;
AVL.SInit(root);
AddCommandsToAVL;
InitStatistics;
InitConfig;
InitSettings;
InitLastResult;
IF Formula.LoadValues(ValuesName) THEN END;
END InitAll;
PROCEDURE SetFillCharP(c:ARRAY OF CHAR);
(* $CopyArrays- *)
BEGIN
IF (c[0]='"') AND (c[1]#0X) AND (c[2]='"') THEN
config.fillChar:=c[1]
ELSE
config.fillChar:=c[0]
END
END SetFillCharP;
PROCEDURE CalculateVariation():LONGREAL;
BEGIN
IF statistics.counter>1 THEN
RETURN (statistics.sumOfSquares-
(MATHLIB.SQR(statistics.sum)/statistics.counter))/
(statistics.counter-1);
ELSE
settings.error:=VariationError;
RETURN MAX(LONGREAL)
END;
END CalculateVariation;
PROCEDURE UseFormula(expression:ARRAY OF CHAR);
(* $CopyArrays- *)
BEGIN
IF expression#"" THEN
IF NOT settings.useFormula AND
Formula.GetIndex(UseVarName,settings.useVarIndex) THEN
WriteStringLn('Attention: This changes value "x"')
END;
InitUseVar;
IF NOT Formula.Compile(expression,useFormula) THEN
IF NOT Formula.RemoveValue(UseVarName) THEN ImpErr END;
settings.useFormula:=FALSE;
io.WriteString("New Formula: ");
WriteErrorLn(Formula.ErrorText[useFormula.error]);
ELSE
COPY(expression,settings.useFormulaExpression);
settings.useFormula:=TRUE
END;
ELSE
IF settings.useFormula THEN
IF NOT Formula.RemoveValue(UseVarName) THEN ImpErr END;
settings.useFormula:=FALSE;
END;
END;
END UseFormula;
PROCEDURE Printer(on:BOOLEAN);
BEGIN
IF on THEN
GetPrintWidth;
IF NOT settings.printerOn THEN
printerPtr:=SecureDos.Open(PrinterName,Dos.newFile);
IF printerPtr#NIL THEN
settings.printerOn:=TRUE
ELSE
(*settings.printerOn:=FALSE;*)
settings.error:=PrinterError;
END;
END;
ELSE
IF settings.printerOn THEN
SecureDos.Close(printerPtr);
printerPtr:=NIL;
settings.printerOn:=FALSE
END;
END;
END Printer;
PROCEDURE OpenFileP(name:ARRAY OF CHAR);
(* $CopyArrays- *)
BEGIN
GetPrintWidth;
IF settings.fileOpen THEN
WriteErrorLn("A file is already open")
ELSE
IF name#"" THEN
settings.fileOpen:=TF.Open(file,name,1024,TF.newFile)
END;
IF NOT settings.fileOpen THEN
WriteErrorLn("Can't open file")
ELSE
COPY(name,settings.filename)
END;
END;
END OpenFileP;
PROCEDURE CloseFileP;
BEGIN
IF settings.fileOpen THEN
IF NOT TF.Close(file) THEN ImpErr END;
settings.fileOpen:=FALSE;
settings.filename:="";
ELSE
WriteErrorLn("A file is not open")
END;
END CloseFileP;
PROCEDURE DoStatistics(x:LONGREAL);
BEGIN
INC(statistics.counter);
statistics.sum:=statistics.sum+x;
statistics.sumOfSquares:=statistics.sumOfSquares+MATHLIB.SQR(x);
statistics.lastInput:=x;
(*statistics.on:=TRUE;*)
statistics.canUndo:=TRUE;
END DoStatistics;
PROCEDURE StatisticsUndoP():BOOLEAN;
BEGIN
IF statistics.canUndo THEN
DEC(statistics.counter);
statistics.sum:=statistics.sum-statistics.lastInput;
statistics.sumOfSquares:=statistics.sumOfSquares-
MATHLIB.SQR(statistics.lastInput);
statistics.lastInput:=0;
(*statistics.on:=TRUE;*)
statistics.canUndo:=FALSE;
RETURN TRUE
ELSE
RETURN FALSE
END;
END StatisticsUndoP;
PROCEDURE Status;
BEGIN
WriteString("Status: ");
WriteStringLn(IText[settings.error]);
IF settings.error#NoError THEN
Beep.Beep(TRUE);
Intuition.DisplayBeep(NIL);
END;
END Status;
PROCEDURE WriteStatistics;
VAR v:LONGREAL;
BEGIN
WriteString("Statistics");
IF statistics.on THEN
WriteStringLn(IsOn)
ELSE
WriteStringLn(IsOff)
END;
WriteString("Number of inputs: ");
WriteInt(statistics.counter,8);
WriteString("Sum of inputs: ");
WriteReal(statistics.sum);
WriteString("Sum of squares:");
WriteReal(statistics.sumOfSquares);
IF statistics.counter>1 THEN
WriteString("Meanvalue:");
WriteReal(statistics.sum/statistics.counter);
WriteString("Variation:");
v:=CalculateVariation();
WriteReal(v);
WriteString("Standarddeviation:");
WriteReal(MATHLIB.SQRT(v));
END;
END WriteStatistics;
PROCEDURE InfoP;
BEGIN
WriteString(Color3);
Status;
WriteStringLn("\nStatistics:");
WriteString(ResetColor);
WriteStatistics;
WriteString(Color3);
WriteString("\nOutputformat:");
WriteString(ResetColor);
WriteString("\nTotal number of digits: ");
WriteInt(config.gs,3);
WriteString("Digits behind decimalpoint: ");
WriteInt(config.nks,3);
WriteString("Exponent");
IF config.expo THEN
WriteStringLn(IsOn)
ELSIF config.autoExpo THEN
WriteStringLn(" is used if ABS(x)<1")
ELSE
WriteStringLn(IsOff)
END;
IF config.leftJustify THEN
WriteStringLn("Result is left justified")
ELSE
WriteStringLn("Result is right justified")
END;
IF config.printAll THEN
WriteStringLn("Input and result is printed")
ELSE
WriteStringLn("Only result is printed")
END;
WriteString("Fillcharacter is ");
IF (config.fillChar=Space) THEN
WriteString("Space")
ELSIF (config.fillChar=0X) THEN
WriteString("0X")
ELSE
Write(config.fillChar)
END;
WriteString(Color3);
WriteString("\n\nOther settings:");
WriteStringLn(ResetColor);
IF settings.useFormula THEN
WriteString("Formula ");
WriteString(settings.useFormulaExpression);
WriteStringLn(" is used")
ELSE
WriteStringLn("No Formula is used")
END;
WriteString("Printer");
IF settings.printerOn THEN
WriteStringLn(IsOn)
ELSE
WriteStringLn(IsOff);
END;
IF settings.fileOpen THEN
WriteString("File ");
WriteString(settings.filename);
WriteStringLn(" is open\n");
ELSE
WriteStringLn("A file is not open\n");
END;
END InfoP;
PROCEDURE* WriteCommand(el:AVL.NodePtr);
BEGIN
IF el IS ComNode THEN
WriteStringLn(el(AVL.SNode).name);
END;
END WriteCommand;
PROCEDURE ShowCommandsP;
BEGIN
WriteString(Color3);
WriteStringLn(" Type a numerical expression or one of the following commands");
WriteString(ResetColor);
AVL.DoForward(root,WriteCommand);
WriteLn;
END ShowCommandsP;
PROCEDURE Copyright;
BEGIN
WriteString(Color3);
WriteStringLn(CRString0);
WriteStringLn(CRString1);
WriteStringLn(CRString2);
WriteStringLn(CRString3);
WriteStringLn(ResetColor);
END Copyright;
PROCEDURE HelpP;
BEGIN
Copyright;
ShowCommandsP;
END HelpP;
PROCEDURE GetFormat(f:ARRAY OF CHAR):BOOLEAN;
(* $CopyArrays- *)
VAR
ok:BOOLEAN;
f1:String80;
i:INTEGER;
gs,nks:LONGINT;
expo:BOOLEAN;
BEGIN
Formula.DeleteSpaces(f);
IF f="" THEN RETURN FALSE END;
i:=Strings.Length(f)-1;
IF f[i]='E' THEN
expo:=TRUE;
f[i]:=0X;
ELSE
expo:=FALSE
END;
IF Formula.Split(f,f1,'.') THEN END;
IF (f#'') THEN
ok:=Conversions.StringToInt(f,gs);
ELSE
gs:=config.gs; (* use old value *)
ok:=TRUE
END;
IF (f1#'') THEN
ok:=ok AND Conversions.StringToInt(f1,nks);
ELSE
nks:=config.nks; (* use old value *)
END;
IF ok AND (gs>0) AND (gs<=MaxDigits) AND (nks>=0)
AND (nks<=MaxDigits) THEN
config.expo:=expo;
config.gs:=SHORT(gs);
config.nks:=SHORT(nks);
RETURN TRUE;
ELSE
RETURN FALSE
END;
END GetFormat;
PROCEDURE Calc;
VAR
lastChar:INTEGER;
name:AVL.String;
expression:String512;
comment:String80;
x:LONGREAL;
trash:BOOLEAN;
BEGIN;
Formula.Divide(input,name,expression,comment);
IF NOT (Formula.Compile(expression,formula) AND
Formula.Evaluate(formula,x)) THEN
WriteErrorLn(Formula.ErrorText[formula.error]);
RETURN;
END;
IF settings.useFormula THEN
Strings.Insert(expression,0,"Formula(");
Strings.AppendChar(expression,")");
Formula.ChangeValue(settings.useVarIndex,x);
IF NOT Formula.Evaluate(useFormula,x) THEN
io.WriteString("Using Formula: ");
WriteErrorLn(Formula.ErrorText[useFormula.error]);
RETURN;
END;
END;
IF statistics.on THEN DoStatistics(x) END;
IF name#'' THEN
lastChar:=Strings.Length(name)-1;
IF name[lastChar]=":" THEN
trash:=FALSE;
name[lastChar]:=0X;
Formula.DeleteSpaces(name);
ELSE
trash:=TRUE
END;
lastChar:=Strings.Length(name);
IF Formula.DefineValue(name,x,trash,comment) THEN
WriteString(name);
IF config.printAll THEN
WriteString(" := ");
INC(lastChar,4);
END;
ELSE
WriteErrorLn('Name is not correct')
END;
ELSE
lastChar:=0;
END;
IF config.printAll THEN
WriteString(expression);
IF config.leftJustify THEN INC(lastChar,config.gs)
ELSE INC(lastChar,MaxDigits) END;
INC(lastChar,Strings.Length(expression)+(PME+2+1));
(* +2 for "= ", +1 for security *)
IF lastChar>=settings.printWidth THEN
WriteLn;
ELSE
WriteFillChar(settings.printWidth-lastChar);
END
END;
WriteRealRemember(x);
END Calc;
BEGIN
InitAll;
io.WriteString(Clear);
Copyright;
LOOP
io.WriteString(" : ");
io.ReadString(input);
Formula.DeleteSpaces(input);
tmp1:=input;
IF Formula.Split(tmp1,tmp2,Space) THEN
Formula.DeleteSpaces(tmp2);
END;
COPY(tmp1,command);
el:=AVL.SFind(root,command);
IF el#NIL THEN (* el IS ComNode *)
id:=el(ComNode).id;
IF id#Empty THEN io.WriteLn END;
ELSE
id:=Calculate;
END;
CASE id OF
Empty:WriteLn|
Calculate:Calc|
Quit,Point:EXIT|
Help:HelpP|
Info:InfoP|
ShowCommands:ShowCommandsP|
ShowFunctions:Formula.WriteFunctions(WriteStringLn);WriteLn|
ShowValues:Formula.WriteValues(WriteStringLn);WriteLn|
ResetStatistics:InitStatistics|
StatisticsOn:statistics.on:=TRUE|
StatisticsOff:statistics.on:=FALSE|
SetFillChar:SetFillCharP(tmp2)|
Format:IF NOT GetFormat(tmp2) THEN
WriteErrorLn("Format is not correct");
END|
FormulaOff:UseFormula("")|
FormulaOn:UseFormula(tmp2)|
PrinterOn:Printer(TRUE)|
PrinterOff:Printer(FALSE)|
PrintAll:config.printAll:=TRUE|
PrintResult:config.printAll:=FALSE|
OpenFile:OpenFileP(tmp2)|
CloseFile:CloseFileP|
LeftJustify:config.leftJustify:=TRUE|
RightJustify:config.leftJustify:=FALSE|
ExponentOn:config.expo:=TRUE|
ExponentOff:config.expo:=FALSE|
AutoExpoOn:config.autoExpo:=TRUE|
AutoExpoOff:config.autoExpo:=FALSE|
DisposeAllValues:
IF settings.useFormula THEN
WriteErrorLn("Can't dispose values if Formula is on")
ELSE
Formula.DisposeAllValues;
InitLastResult;
END|
LoadConfig:
IF tmp2="" THEN tmp2:=ConfigName END;
IF NOT LoadConfigP(tmp2) THEN
WriteErrorLn("Can't load configuration");
END|
SaveConfig:
IF tmp2="" THEN tmp2:=ConfigName END;
IF NOT SaveConfigP(tmp2) THEN
WriteErrorLn("Can't save configuration");
END|
LoadValues:
IF tmp2="" THEN tmp2:=ValuesName END;
IF NOT Formula.LoadValues(tmp2) THEN
WriteErrorLn("Can't load values");
END|
SaveValues:
IF tmp2="" THEN tmp2:=ValuesName END;
IF NOT Formula.SaveValues(tmp2) THEN
WriteErrorLn("Can't save values");
END|
RemoveValue:
IF settings.useFormula THEN
WriteErrorLn("Can't remove value if Formula is on")
ELSE
IF NOT Formula.RemoveValue(tmp2) THEN
WriteErrorLn("Can't remove this value")
END
END|
DigitsBehindPoint:
IF Conversions.StringToInt(tmp2,l) AND (l>=0)
AND (l<=MaxDigits) THEN
config.nks:=SHORT(l)
ELSE
WriteErrorLn("Wrong number of digits behind the decimal point")
END|
TotalDigits:
IF Conversions.StringToInt(tmp2,l) AND (l>0)
AND (l<=MaxDigits) THEN
config.gs:=SHORT(l)
ELSE
WriteErrorLn("Wrong number of total digits")
END|
StatisticsUndo:
IF NOT StatisticsUndoP() THEN
WriteErrorLn("Can't undo last operation")
END|
SumOfInputs:
WriteRealRemember(statistics.sum)|
MeanValue:
IF statistics.counter>0 THEN
WriteRealRemember(statistics.sum/statistics.counter)
ELSE
WriteErrorLn("Number of inputs is zero")
END|
SumOfSquares:
WriteRealRemember(statistics.sumOfSquares)|
StatisticsCounter:
WriteInt(statistics.counter,8);
Formula.ChangeValue(settings.lastResultIndex,
statistics.counter)|
Variation:
IF statistics.counter>1 THEN
WriteRealRemember(CalculateVariation())
ELSE
WriteErrorLn("Can't calculate Variation")
END|
StandardDeviation:
IF statistics.counter>1 THEN
WriteRealRemember(MATHLIB.SQRT(CalculateVariation()));
ELSE
WriteErrorLn("Can't calculate Standarddeviation")
END|
ELSE
ImpErr
END;
END;
CLOSE
Status;
IF settings.printerOn THEN
SecureDos.Close(printerPtr);
END;
IF settings.fileOpen THEN
IF TF.Close(file) THEN END;
END;
END ROM20.